import { useLazyQuery } from "@apollo/client";
import { getOrdersByUserAndOrg_service } from "../../graphql/student";
import { OrderType } from "../../types/order";

export const useGetOrdersByOrg = () => {
  const [get, { data, loading }] = useLazyQuery(getOrdersByUserAndOrg_service, {
    fetchPolicy: "network-only"
  });
  const getOrders = () => {
    void get({
      variables: {
        transmitUserId: "onlyOrg"
      }
    });
  };
  return {
    getOrders,
    data: data?.getOrdersByUserId.data as OrderType[],
    loading
  };
};
